#pragma once


struct LoginInfo
{
    QString strIp;
    QString userName;
    QString token;
};

class HConnectionManager : public QObject
{
    Q_OBJECT
public:
    HConnectionManager();
    ~HConnectionManager();

    static HConnectionManager& GetInstance();

    bool GetInfoByConnection(QTcpSocket* pSock, LoginInfo& info);

    void SetInfoByConnection(QTcpSocket* pSock, LoginInfo& info);

    QTcpSocket* GetSockByUserName(QString const& userName);

    void DeleteConnectionBySock(QTcpSocket* pSock);

    void DeleteConnectionByUserName(QString const& userName);

    QVector<LoginInfo> GetLoginInfoList();

public slots:
    void OnSocketClosed();

private:
    QMap<QTcpSocket*, LoginInfo> m_ConnectionMap;
};

